package com.healthbox.appointmentservice.common;

import lombok.*;

import java.io.Serializable;

@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class Result<T> implements Serializable {
    private int code;
    private String msg;
    private T data;

    public static <T> Result<T> ok(T data) {
        return new Result<T>(200, "success", data);
    }

    public static <T> Result<T> badRequest() {
        return new Result<T>(400, "Bad Request", null);
    }

    public static <T> Result<T> badRequest(String msg) {
        return new Result<T>(400, msg, null);
    }

    public static <T> Result<T> noAuthorization() {
        return new Result<T>(400, "No Authorization", null);
    }

    public static <T> Result<T> noAuthorization(String msg) {
        return new Result<T>(400, msg, null);
    }

    public static <T> Result<T> notFound() {
        return new Result<T>(404, "Not Found", null);
    }
}
